-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move CSS reset, font loading and theme switch outside React to prevent flicker #494
base: development
Are you sure you want to change the base?
Conversation
@@ -26,10 +26,9 @@ export const Wrapper = styled(motion.div)<{ | |||
expanded?: boolean; | |||
}>` | |||
position: relative; | |||
width: ${(props) => (props.responsive ? "100%" : "377.5px")}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This .5
seem to fix some rendering issues (underflow) in some cases but cause another issue (overflow) in some other cases. I'd just leave it as 377px
which is the actual value this should have everywhere and fix it later by laying out the components differently.
min-height: ${(props) => (props.expanded ? "100vh" : "600px")}; | ||
max-height: max-content; | ||
background-color: rgb(${(props) => props.theme.background}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The background is set on the body
by the ThemeProvider
in the components library, so no need to set it again here.
src/popup.tsx
Outdated
</ExpandedViewWrapper> | ||
</HardwareWalletTheme> | ||
</Provider> | ||
<ArConnectThemeProvider> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ArConnectThemeProvider
replaces Provider
+ HardwareWalletTheme
and used the useTheme
hook internally.
@@ -356,7 +372,50 @@ export default function Transaction({ id: rawId, gw, message }: Props) { | |||
{browser.i18n.getMessage("transaction_from")} | |||
</PropertyName> | |||
<PropertyValue> | |||
{formatAddress(transaction.owner.address, 6)} | |||
<div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually, it would be better to turn this into a bunch of individual components.
In any case, the reason for this change is that before the UI would only prompt users to add the "to" address as contact. After this change, it would prompt for both "to" and "from", and it would also take into account if an address is yours and display "(you)" next to it.
- Stop using Route for the Unlock view. - Make initial fade-in faster.
isOpen: boolean; | ||
onClose?: () => void; | ||
children?: React.ReactNode; | ||
} | ||
|
||
export default function SliderMenu({ | ||
title, | ||
hasNav, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Send view, the last option inside the menus was covered by the bottom navigation.
…d on browser preferences.
const themeModifier = hardwareApi ? hardwareThemeModifier : noThemeModifier; | ||
|
||
useEffect(() => { | ||
const reducedMotionPreference = window.matchMedia( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this here. It could eventually be added in settings too, just like the system theme can be overridden.
> | ||
<BackButtonIcon /> | ||
</BackButton> | ||
{showBack ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional was missing here, so that option did nothing.
</AnimatePresence> | ||
</ButtonAvatar> | ||
</AvatarButton> | ||
{showOptions ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This other one was probably implemented incorrectly and allowOpen
(now removed) and showOptions
were redundant but not implemented properly. No, the lock screen should only show the title at the top, no back button or wallet selector.
@@ -27,18 +26,6 @@ export default function HistoryProvider({ children }: PropsWithChildren<{}>) { | |||
history.back(); | |||
}; | |||
|
|||
// redirect to unlock if decryiption | |||
// key is not available | |||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic moved to useSetUp()
in ArConnect/src/wallets/index.ts
.
@@ -14,32 +14,18 @@ const Route: typeof BaseRoute = ({ path, component, children }) => { | |||
? children(params) | |||
: children; | |||
|
|||
return ( | |||
<AnimatePresence initial={false}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a single AnimatePresence
in popup.tsx
.
background-color: rgb(${(props) => props.theme.background}); | ||
`; | ||
|
||
const PageWrapper = styled(Wrapper)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were some unnecessary containers (HTML) that is now gone, so the HTML structure should look much simpler:
body > #__plasmo > main#Page
@@ -242,18 +234,23 @@ export default function WalletHeader() { | |||
} | |||
} | |||
]; | |||
if (!isExpanded && items.length === 4) { | |||
|
|||
if (location.pathname === "/popup.html") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The full screen version is now loaded from a different HTML file: fullscreen.html
, so all these checks are now much simpler and the styling changes require no JS.
// lock wallet and terminate session | ||
async function lockWallet() { | ||
await removeDecryptionKey(); | ||
push("/unlock"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a route change anymore. Removing the decryption key makes the root re-render automatically, showing the Unlock screen.
|
||
// init popup | ||
useSetUp(); | ||
const initialScreenType = useSetUp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The route guarding logic now lives here and doesn't rely on routes to work. That applies to the Unlock screen and an "undefined" state when the app first loads. This will also include a state and UI for the "creating wallet" state of the embedded wallet.
display: none | ||
} | ||
if (initialScreenType === "cover") { | ||
content = <Page />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty page. Does nothing but wait.
// This can only happen in the embedded wallet: | ||
content = ( | ||
<Page> | ||
<p>Generating Wallet...</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placeholder for the embedded wallet. This does nothing right now, but I'll update it in the other PR once this one is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK 👍
localStorage
to remove theme flicker.